/*
 * @description: 
 * @version: 1.0.1
 * @Author: xuqiulin
 * @Date: 2021-06-08 19:12:54
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-06-08 20:21:39
 */
const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    bstart: boolean = false;// true：正在滚动
    fspeed: number = 0;// 滚动速度

    onLoad () {
        this.bstart = false;
        this.fspeed = 100;
    }

    start () {

    }

    update (dt: number) {
        if (this.bstart) {
            this.roll(dt);
        }
    }

    startRoll () {
        if (!this.bstart) {
            this.bstart = true;
        }
    }

    roll (dt: number) {
        let bg0 = this.node.children[0];
        let bg1 = this.node.children[1];
        bg0.y -= this.fspeed*dt;
        bg1.y -= this.fspeed*dt;
        if (bg1.y <= 0) {
            bg0.y = 0;
            bg1.y = bg1.height;
        }
    }
}
